using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Magiq.Behaviors;

namespace Magiq.Insert
{
    public class InsertBuilder<TSource, TDestination> : IInsertBuilder<TSource, TDestination> where TDestination : class
    {
        private readonly IEnumerable<TDestination> destination;
        private readonly IMagiqBehavior behavior;
        private readonly IEnumerable<TSource> source;

        public InsertBuilder(IEnumerable<TSource> source, IEnumerable<TDestination> destination, IMagiqBehavior behavior)
        {
            this.destination = destination;
            this.behavior = behavior;
            this.source = source;
        }

        public int Insert<TNew>(Expression<Func<TSource, TNew>> newExpression) where TNew : class, TDestination, new()
        {
            var insert = new Insert<TSource, TDestination, TNew>(source, newExpression, destination, behavior);
            return insert.Execute();
        }
    }
}